package org.neuedu.servlet;

import org.neuedu.bean.Article;
import org.neuedu.bean.Detail;
import org.neuedu.bean.IndexLoader;
import org.neuedu.bean.User;
import org.neuedu.service.ArticleService;
import org.neuedu.service.ArticleServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet(name = "ByUidServlet",urlPatterns = "/forward/user/index")
public class ByUidServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String uid = request.getParameter("uid");

        ArticleService articleService =new ArticleServiceImpl();


        IndexLoader articleById = articleService.getArticleById(Integer.valueOf(uid));

        request.setAttribute("indexInfo",articleById);

        request.getRequestDispatcher("/WEB-INF/jsp/user/index.jsp").forward(request,response);

    }
}
